package com.casic.ops.entity.vo;

import com.casic.ops.consts.app.StageType;
import com.casic.ops.entity.domain.ApplicationPipelineDetailDO;
import com.orion.utils.convert.TypeStore;
import lombok.Data;

/**
 * @ClassName ops-platform
 * @Description  应用流水线详情
 * @Author mianbin
 * @Date 2022/5/31 10:59
 * @Version 1.0
 **/
@Data
public class ApplicationPipelineStatisticsDetailVO {

    /**
     * id
     */
    private Long id;

    /**
     * 应用id
     */
    private Long appId;

    /**
     * 应用名称
     */
    private String appName;

    /**
     * 阶段类型 10构建 20发布
     *
     * @see StageType
     */
    private Integer stageType;

    /**
     * 平均操作时长ms (成功)
     */
    private Long avgUsed;

    /**
     * 平均操作时长 (成功)
     */
    private String avgUsedInterval;

    public static ApplicationPipelineStatisticsDetailVO pipelineDetailDO2pipelineStatisticsDetailVO(ApplicationPipelineDetailDO p) {
        ApplicationPipelineStatisticsDetailVO vo = new ApplicationPipelineStatisticsDetailVO();
        vo.setId(p.getId());
        vo.setAppId(p.getAppId());
        vo.setStageType(p.getStageType());
        return vo;
    }

    static {
        TypeStore.STORE.register(ApplicationPipelineDetailDO.class, ApplicationPipelineStatisticsDetailVO.class, p -> {
            ApplicationPipelineStatisticsDetailVO vo = new ApplicationPipelineStatisticsDetailVO();
            vo.setId(p.getId());
            vo.setAppId(p.getAppId());
            vo.setStageType(p.getStageType());
            return vo;
        });
    }

}
